//
//  MBProgressHUD+ATAdd.h
//  Postre
//
//  Created by CoderLT on 2017/5/24.
//  Copyright © 2017年 CoderLT. All rights reserved.
//

#import <MBProgressHUD/MBProgressHUD.h>

#define MBHudShowMaxDuration (30)
#define MBHudHideDelay       (1)
#define MBHudGraceTime       (0.8)

@interface MBProgressHUD (ATAdd)
+ (UIView *)defaultView;
+ (UIImage *)defaultSuccessImage;
+ (UIImage *)defaultFailureImage;


/**
 显示Loding加载提示Hud, 禁用用户交可使用 hud.userInteractionEnabled = YES;

 message 提示语
 view 所在的视图层
 gractTime 延迟显示时间, 如果在该时间前操作完成 隐藏Hud, 则不显示Hud
 delay 延迟消失时间, 默认30秒超时, 自动隐藏.
 completion 可以这个回调中去执行需要的操作
 @return Hud实例, 更多请参考 MBProgressHud
 */
+ (instancetype)showMessage:(NSString *)message;
+ (instancetype)showMessage:(NSString *)message toView:(UIView *)view;
+ (instancetype)showWithCompletion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;
+ (instancetype)showToView:(UIView *)view completion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;
+ (instancetype)showMessage:(NSString *)message completion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;
+ (instancetype)showMessage:(NSString *)message toView:(UIView *)view completion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;
+ (instancetype)graceShowMessage:(NSString *)message toView:(UIView *)view completion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;
+ (instancetype)showMessage:(NSString *)message
                     toView:(UIView *)view
                  graceTime:(NSTimeInterval)gractTime
             hideAfterDelay:(NSTimeInterval)delay
                 completion:(void (^NS_NOESCAPE)(MBProgressHUD *hud))completion;

/**
 隐藏HUd
 
 message 事件执行完成后, 显示"操作成功"等 然后隐藏Hud
 image 事件执行完成后, 显示"✅❌"等 然后隐藏Hud
 animated 是否需要动画
 delay 延迟消失时间
 completion Hud消失后回调
 */
+ (instancetype)hudForView:(UIView *)view;
- (void)hideWithMessage:(NSString *)message completion:(MBProgressHUDCompletionBlock)completion;
- (void)hideWithSuccess:(NSString *)message completion:(MBProgressHUDCompletionBlock)completion;
- (void)hideWithFailure:(NSString *)message completion:(MBProgressHUDCompletionBlock)completion;
- (void)hideWithAnimated:(BOOL)animated completion:(MBProgressHUDCompletionBlock)completion;
- (void)hideWithMessage:(NSString *)message
                  image:(UIImage *)image
               animated:(BOOL)animated
                  delay:(NSTimeInterval)delay
             completion:(MBProgressHUDCompletionBlock)completion;
@end
